package io.renren.modules.task.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.task.entity.VehicleEntity;
import io.renren.modules.task.service.VehicleService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 报抽任务
 *
 * @author test
 * @email test@test.com
 * @date 2023-06-03 23:19:38
 */
@RestController
@RequestMapping("generator/vehicle")
public class VehicleController {
    @Autowired
    private VehicleService vehicleService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:vehicle:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = vehicleService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("generator:vehicle:info")
    public R info(@PathVariable("id") Integer id){
		VehicleEntity vehicle = vehicleService.getById(id);

        return R.ok().put("vehicle", vehicle);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:vehicle:save")
    public R save(@RequestBody VehicleEntity vehicle){
		vehicleService.save(vehicle);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:vehicle:update")
    public R update(@RequestBody VehicleEntity vehicle){
		vehicleService.updateById(vehicle);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:vehicle:delete")
    public R delete(@RequestBody Integer[] ids){
		vehicleService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
